<?php
/**
 * @version      1.0.1
 * @package	ResMania Search
 * @copyright	Copyright (C) 2009 - 2010. All rights reserved.
 * @license	GNU/GPL
 * This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License.
 * see http://resmania.com/license for more information.
 */
// no direct access
defined('_JEXEC') or die('Restricted access');

// resmania search object
$RMSobj = new modResManiaSearch;
$config = $RMSobj->getConfig(); // get the config

if ($config === false) {
    echo "ResMania not installed!";
    return;
}
?>
<!-- dhtmlx calendar -->
<script type="text/javascript" src="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/calendar/calendar.js"></script>
<script type="text/javascript" src="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/calendar/common.js"></script>
<link href="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/calendar/calendar.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/calendar/calendar_override.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/calendar/skins/dhtmlxcalendar_<?php echo trim($dpSkinName); ?>.css" rel="stylesheet" type="text/css" />

<!-- search form css -->
<link href="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/shadowbox/shadowbox.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/css/searchform.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/css/searchform_override.css" rel="stylesheet" type="text/css" />

<!-- style override with path requirement -->
<style type="text/css">
    #sb-nav-close{
        background-image: url(<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/shadowbox/rm_close.png) !important;
    }
</style>

<!-- shadowbox lib-->
<script language="javascript" type='text/javascript' src='<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/shadowbox/shadowbox.js'></script>
<!-- search form JS -->
<script language="javascript" type='text/javascript' src='<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/js/search.js'></script>

<!-- search form -->
<div class="<?php echo $params->get('moduleclass_sfx') ?>">
    <div class="RM_module_search_container">
        <form action="<?php echo $config->postto; ?>" method="POST" name="RM_module_Search" id="RM_module_Search" >
            <input id="Itemid" name="Itemid" type="hidden" value="<?php echo $advancedItemID; ?>">
            <input id="category" name="category" type="hidden" value="<?php echo $categoryids; ?>">
            <input id="RM_module_startdatetime_hidden" name="search[start_datetime]" type="hidden" value="<?php echo $config->start_datetime; ?>">
            <input id="RM_module_enddatetime_hidden" name="search[end_datetime]" type="hidden" value="<?php echo $config->end_datetime; ?>">
        </form>
        <div id="RM_module_search_dateselector_container">
            <div class="RM_module_dateselector_from">
                <div class="RM_module_date_feild_label"><?php echo JText::_('START_DATE') ?></div>
                <div><input id="RM_module_startdatetime" type="text" value="<?php echo $config->start_datetime; ?>" class="RM_module_text_box" onfocus="RM_Search_Copy_Start_to_End()"/></div>
            </div>
            <div class="RM_module_dateselector_to">
                <div class="RM_module_date_feild_label"><?php echo JText::_('END_DATE') ?></div>
                <div><input id="RM_module_enddatetime" type="text" value="<?php echo $config->end_datetime; ?>" class="RM_module_text_box" /></div>
            </div>
        </div>
        <div class="RM_module_search_adv_searchlink">
            <div class="RM_module_search_adv_searchlink_icon"><img src="<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/images/magnifier.png" border="0"></div><a href="javascript:void(0);" onclick="RM_Joomla_Search_Module_ShowAdvanced();"><?php echo JText::_('ADVANCED_SEARCH') ?></a>
        </div>
        <button class="RM_module_button_rounded" onclick="RM_submitSearch()">
            <span><?php echo JText::_('OK') ?></span>
        </button>
    </div>
</div>
<div style="clear:both;"></div>

<script type="text/javascript">

    var RM_calFormat = '<?php echo $config->dp_dateformat; ?>';
    var RM_lng_Format = '<?php echo $config->dp_lng_dateformat; ?>';
    var RM_submitFormat = 'Y-m-d';

    var RM_normalStyle = {
        backgroundColor: 'white',
        color: 'black'
    }

    var RM_errorStyle = {
        backgroundColor: 'red',
        color: 'black'
    }

    var RM_defaultStyle = {
        backgroundColor: 'white',
        color: 'grey'
    }

    Shadowbox.init({
        language:   "<?php echo RM_Environment::getInstance()->getLocale(true); ?>",
        players:    ["iframe","img"]
    });

    function RM_Joomla_Search_Module_ShowAdvanced(){
        Shadowbox.open({
            content: "<?php echo RM_Environment::getInstance()->getRouter()->_('Search', 'advanced', array('from' => 'search', 'nohtml' => 1, 'Itemid'=>$advancedItemID)) ?>",
            player: "iframe",
            height: 450,
            width:  400
        });
    }

    window.dhx_globalImgPath = "<?php echo $config->siteroot; ?>modules/mod_resmaniasearch/assets/calendar/imgs/";
    var calendars = new dhtmlxCalendarObject(['RM_module_startdatetime', 'RM_module_enddatetime']);
    calendars.setSkin("<?php echo $dpSkinName; ?>");
    calendars.setDateFormat(RM_calFormat);
</script>